package ma.zhiqiang.dataline.core.format;

import ma.zhiqiang.dataline.core.dto.Column;
import ma.zhiqiang.dataline.core.dto.ColumnMap;
import ma.zhiqiang.dataline.core.dto.SinkRecord;

import java.util.StringJoiner;

public class WriterFormatCsv implements WriterFormat{
    @Override
    public String format(SinkRecord sinkRecord) {
        ColumnMap<String, Column> columnMap = (ColumnMap<String, Column>) sinkRecord.getData();
        StringJoiner joiner = new StringJoiner(",");
        columnMap.values().forEach(column -> {
            joiner.add(column.getValue().toString());
        });
        return joiner.toString();
    }
}
